<%@page
	import="com.sun.org.apache.xml.internal.security.utils.HelperNodeList"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Logvan</title>
<link rel="shortcut icon" href="/escolares/html/images/icon/van.png">
<link href="/escolares/html/css/bootstrap.css" rel="stylesheet"
	type="text/css">
<link href="/escolares/html/css/DT_bootstrap.css" rel="stylesheet"
	type="text/css">

<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="/escolares/html/js/bootstrap.js"></script>
<script src="/escolares/html/js/jquery.dataTables.js"></script>
<script src="/escolares/html/js/DT_bootstrap.js"></script>
<script src="/escolares/html/js/bootstrap-datetimepicker.min.js"></script>
<script src="/escolares/html/js/jquery.Rut.min.js"></script>
<script src="/escolares/html/js/jquery.number.min.js"></script>

<script type="text/javascript">
$(function() {
	$('#datetimepicker3').datetimepicker({
		format:"dd/MM/yyyy",
		pickTime : false
	});
	$('#datetimepicker4').datetimepicker({
		format:"dd/MM/yyyy",
		pickTime : false
	});
});
$(document).ready(function() {
	$('.money').number(true, 0, ',', '.');
 	});
</script>

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="container">
		<!-- Main component for a primary marketing message or call to action -->
		<%@include file="../../_common/nav-var.jsp"%>
		<div class="well">
			<s:if test="okMessage=='Operacion realizada exitosamente.'">
				<div class="alert alert-success">
					<s:property value="okMessage" />
				</div>
			</s:if>
			<s:if test="errorMessage=='Se ha producido un error inesperado.'">
				<div class="alert alert-error">
					<s:property value="errorMessage" />
				</div>
			</s:if>
			<h4 style="color: #DA4F49;">Filtrar por:</h4>
			<s:form id="formAlumno" cssClass="form-inline" role="form"
				action="saveAlumno" method="post" theme="simple" namespace="">
				<s:hidden name="usuarioId" value="%{usuarioId}"></s:hidden>

				<div class="control-group" style="margin-left: 50px">
					<div class="controls">
						<s:textfield cssClass="span3" id="tNombresAlumno"
							placeholder="Nombres Alumno" name="nombreAlumno"></s:textfield>

						<s:textfield cssClass="span3" id="tApellidosAlumno"
							placeholder="Apellidos Alumno" name="apellidoAlumno"></s:textfield>

					</div>

					<div class="controls">
						<div id="datetimepicker3" class="input-append">
							<s:textfield  	id="tFechaInicial" name="fechaInicial"
								placeholder="Fecha Inicial"></s:textfield>
							<span class="add-on"> <i data-time-icon="icon-time"
								data-date-icon="icon-calendar"> </i>
							</span>
						</div>
						<div id="datetimepicker4" class="input-append">
							<s:textfield id="tFechaFinal" name="fechaFinal" placeholder="Fecha Final"></s:textfield>
							<span class="add-on"> <i data-time-icon="icon-time"
								data-date-icon="icon-calendar"> </i>
							</span>
						</div>
						<s:checkbox name="filtroFecha" fieldValue="false"
							label="Filtrar por fecha" />
					</div>

					<div class="controls">
						<s:select list="tiposPago" id="sTiposPago" cssClass="span3"
							headerKey="-1" headerValue="Seleccione Tipo" listValue="key"
							listKey="value" name="tipoPago">
						</s:select>
					</div>
					<div class="controls">
						<s:submit action="pagosFilter" id="bSave" key="label.filter"
							cssStyle="margin-left:80px;margin-top:30px;"
							cssClass="btn btn-info" />
					</div>

				</div>
			</s:form>

			<h4 style="color: #DA4F49;">Listado De Pagos</h4>
			<hr class="bs-docs-separator">
			<table class="table table-striped table-bordered" id="example">
				<thead>
					<tr>
						<th>Fecha</th>
						<th>Monto</th>
						<th>Fecha de Pago</th>
						<th>Forma de Pago</th>
						<th>Acciones</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="pagos" var="pago">
						<tr>
							<s:form cssClass="form-inline" role="form" action=""
								method="post" theme="simple" namespace="">
								<s:hidden name="pagoId" value="%{#pago.pagoId}"></s:hidden>
								<td><s:iterator status="fechaMap" value="fechaMap">
										<s:if test="#pago.pagoId == key">
											<s:property value="value"></s:property>
										</s:if>
									</s:iterator></td>
								<td><span>$</span> <s:textfield cssClass="money span2"
										readonly="true" value="%{#pago.monto}"></s:textfield></td>

								<td><s:if test="%{#pago.pagado}">
										<s:iterator status="fechaPagoMap" value="fechaPagoMap">
											<s:if test="#pago.pagoId == key">
												<s:property value="value"></s:property>
											</s:if>
										</s:iterator>
									</s:if> <s:else>No Aplica</s:else></td>
								<td><s:if test="%{#pago.pagado}">
										<s:iterator status="formasPagoMap" value="formasPagoMap">
											<s:if test="#pago.formaPagoId == key">
												<s:property value="value"></s:property>
											</s:if>
										</s:iterator>
									</s:if> <s:else>
										<s:select cssClass="span2"
											headerValue="Selecccione Forma de Pago" list="formasPagoMap"
											listKey="key" listValue="value" name="formaPagoId"></s:select>
									</s:else></td>
								<td><s:if test="%{#pago.pagado}">
										<s:url id="donwloadUrl" action="downloadComprobanteAction">
											<s:param name="pagoId" value="%{#pago.pagoId}" />
										</s:url>
										<s:a href="%{donwloadUrl}" cssClass="btn btn-success">Descargar Comprobante</s:a>

									</s:if> <s:else>

										<s:submit action="savePagoFromTableFilter"
											onclick="return confirm('¿Realmente Desea Recibir el Pago?')"
											cssClass="btn btn-warning" key="label.recibirPago"></s:submit>
									</s:else></td>
								<td><s:url id="deleteUrl" action="deletePago">
										<s:param name="pagoId" value="%{#pago.pagoId}" />
										<s:param name="usuarioId" value="usuario.usuarioId" />
									</s:url> <s:a href="%{deleteUrl}" cssClass="btn btn-danger"
										onclick="return confirm('¿Realmente Desea Anular el Pago?')">Anular</s:a>
								</td>
							</s:form>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
	</div>
</body>
</html>

